<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <button>按钮</button>
  <script>
    var btnEl = document.querySelector("button")
    var foo = function () {
      console.log("监听到按钮的点击")
    }
    btnEl.addEventListener("click", foo)

    // 过5秒后将这个事件监听移除
    setTimeout(() => {
      console.log("将事件监听移除掉")
      btnEl.removeEventListener("click", foo)
    }, 5000);

  </script>
</body>

</html>